package com.yl.order.ui;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.widget.TextView;

import com.yl.common.ui.BaseActivity;
import com.yl.order.R;

/**
 * create by cjx on 2024/5/17
 * desc:
 */
public class FragmentActivity extends BaseActivity {

    public static final String FRAGMENT_SETTING = "FRAGMENT_SETTING";

    Fragment fragment = null;
    TextView operationView;

    public static void startActivity(Context context, String title, String fragment) {
        Intent intent = new Intent(context, FragmentActivity.class);
        intent.setAction(fragment);
        intent.putExtra("title", title);
        context.startActivity(intent);
    }

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_fragment);

        String action = getIntent().getAction();
        String title = getIntent().getStringExtra("title");

        operationView = findViewById(R.id.action);

        findViewById(R.id.close).setOnClickListener(v -> onBackPressed());
        setTitle(title);
        switch (action) {
            case FRAGMENT_SETTING:

                break;
        }
        if (fragment != null) {
            startFragment(R.id.container, fragment);
        }
    }

    public void setTitle(String title) {
        ((TextView) findViewById(R.id.title)).setText(title);
    }
}
